<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作业回顾完成</title>
    <style>
        .active{
            color: red;
        }
    </style>
</head>
<body>
    <div id="app">
        <ul>
            <li :class="{active:currentIndex==index}" v-for="(value,index) in movies" @click="setClass(index)">{{value}}</li>
        </ul>
    </div>
</body>
    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                movies: [
                    '海王',
                    '复仇者',
                    '终结者',
                    '蜘蛛侠',
                    '钢铁侠',
                ],
                currentIndex: 0,
            },
            methods: {
                setClass (index){
                    this.currentIndex = index;
                }
            },
        })
    </script>
</html>